Skip to content

Omit the id of an error response when it is unknown - #607

Closed
dominikklein wants to merge 1 commit into
modelcontextprotocol:mainfrom
dominikklein:omit_unknown_ids_from_error_responses
Closed

dominikklein wants to merge 1 commit into
modelcontextprotocol:mainfrom
dominikklein:omit_unknown_ids_from_error_responses

Conversation

@dominikklein

Copy link
Copy Markdown

MCP's error responses have an optional string or integer id, so an id the server couldn't read is now left out instead of being sent as null. This covers JsonRpcHandler.error_response and the transport's json_rpc_error_response and invalid_request_response. A wrong content type now returns:

{"jsonrpc":"2.0","error":{"code":-32600,"message":"Unsupported Media Type: Content-Type must be application/json"}}

The tests that checked for a nil id now check that the member is absent, including the listen test that asserted null on purpose.

Fixes #606.

MCP's error responses have an optional string or integer id, so an id
the server couldn't read is now left out instead of being sent as null.

Fixes modelcontextprotocol#606.
@koic

koic commented Oct 15, 2026

Copy link
Copy Markdown
Member

Closing in favor of #615, which leaves the id member out in the same three builders and adds three things: a refusal carrying a readable integer id, 0 included, is checked to still echo it, the stdio transport tests pin the absence as well,
and the commit message records the interoperability cost for the Python client, whose JSONRPCError requires the member and falls back to its own generic error on a refused POST.

Thank you for the report and the schema references in #606.

@koic koic closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error responses carry "id": null, which the MCP schema does not allow

2 participants